import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { SearchService } from './search.service';

@Controller('search')
export class SearchController {
  constructor(private readonly searchService: SearchService) {
  }

  @Get()
  async searchArticles(
    @Query('keyword') keyword: string,
    @Query('pageNo') pageNo: number,
    @Query('pageSize') pageSize: number,
  ) {
    pageNo = pageNo || 1;
    pageSize = pageSize || 10;
    return await this.searchService.searchArticles(keyword, pageNo, pageSize);
  }
}
